﻿using System;
using System.Collections.Generic;
using System.DirectoryServices.AccountManagement;

namespace Red.Launcher.ViewModels.Workspaces.Database
{
    public class ADGroupToClientSpecs : Record
    {
        #region Inherited Properties

        public override Metadata Metadata { get { return METADATA; } }
        public override string Icon { get { return "appbar_os_windows_8"; } }
        public override IEnumerable<object> Values { get { return new List<object>() { Name, Guid }; } }

        #endregion Inherited Properties

        #region Public Properties

        public static Metadata METADATA { get; private set; }
        public Guid Guid { get; private set; }

        #endregion Public Properties

        #region C-Tor

        static ADGroupToClientSpecs()
        {
            METADATA = new Metadata()
            {
                Table = "ADGroupToClientSpecs",
                Keys = new List<string>() { "name", "guid" },
                CreateDefault = () => { return null; },
                CreateFromDatabaseRow = ( Dictionary<string, object> data ) =>
                {
                    return new ADGroupToClientSpecs()
                    {
                        Id = (int)data[ "id" ],
                        Guid = (Guid)data[ "guid" ],
                        Name = (string)data[ "name" ]
                    };
                }
            };
        }

        public ADGroupToClientSpecs( GroupPrincipal group )
        {
            Guid = (Guid)group.Guid;
            Name = group.ToString();
        }

        private ADGroupToClientSpecs()
        {
        }

        #endregion C-Tor
    }
}
